package personal.zq.practice.common.constants;

public class WxConstants {

    /**
     * 消息
     */
    private static final String MESSAGE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=%s";
    /**
     * token
     */
    private static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
    /**
     * jscode2session
     */
    private static final String JSCODE_SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session?grant_type=authorization_code&appid=%s&secret=%s" +
            "&js_code=%s";

    private WxConstants() {
    }

    public static String getTokenUrl(String appid, String secret) {
        return String.format(ACCESS_TOKEN_URL, appid, secret);
    }

    public static String getMessageUrl(String token) {
        return String.format(MESSAGE_SEND_URL, token);
    }

    public static String getCode2SessionUrl(String appid, String secret, String code) {
        return String.format(JSCODE_SESSION_URL, appid, secret, code);
    }
}
